package com.hydra.wiki.graph.entity;

import com.google.common.collect.Sets;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.neo4j.ogm.annotation.GraphId;
import org.neo4j.ogm.annotation.Labels;
import org.neo4j.ogm.annotation.NodeEntity;

import java.util.HashSet;
import java.util.Set;

@Data
@Builder
@NodeEntity
@NoArgsConstructor
@AllArgsConstructor
public class Entity {

    @GraphId
    private Long id;

    @Labels
    private Set<String> labels = new HashSet<>();

    private String name;

    private String desc;

    public void addLabel(String label){
        labels.add(label);
    }

    public void setLabels(String label) {
        addLabel(label);
    }

    public void setLabels(String[] labels) {
        this.labels.addAll(Sets.newHashSet(labels));
    }

    public void setLabels(Set<String> labels) {
        this.labels = labels;
    }
}
